package com.easy.orm.jdbc.support;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.easy.orm.jdbc.ParamsMapper;

/**
 * 
 * 数组参数设置
 * 
 * @author kun
 *
 */
public class ArrayParamsMapper implements ParamsMapper<Object[]> {

	/**
	 * <b>参数处理</b>
	 * 
	 * @param preparedStatement preparedStatement
	 *            {@linkplain java.sql.PreparedStatement}
	 * @param params 设置参数
	 * @throws SQLException 处理异常
	 */
	@Override
	public void setParams(PreparedStatement preparedStatement, Object[] params) throws SQLException {
		// 判断 参数是否存在
		if (params == null || params.length == 0) {
			return;
		}

		// 设置参数
		for (int index = 0; index < params.length; index++) {
			preparedStatement.setObject(index + 1, params[index]);
		}
	}
}
